package in.electromedicalabs.moviesorter;

import java.awt.ComponentOrientation;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

/**
 * Creates status screen and displays status messages
 * 
 * @author @nkit Prasad & Bhavin Mehta
 * @version $Revision: 1.0 $
 */
public class StatusScreen {

	private static final int TEXT_AREA_WIDTH = 350; // lines
	private static final int TEXT_AREA_HEIGHT = 55; // lines
	private static final int STATUS_SCREEN_WIDTH = 600; // pixels
	private static final int STATUS_SCREEN_HEIGHT = 400; // pixels
	private static final int CLOSE_OPERATION_VALUE = 3;

	private static JFrame mainFrame;
	private static JPanel mainPanel;
	private static JScrollPane scrollPanel;
	private static JTextArea statusArea;
	private static FlowLayout layout;
	private static JProgressBar jPb;

	/**
	 * Forms the status display screen
	 */
	public static void startStatusDisplay() {
		mainFrame = new JFrame(
				"Movie-Sorter 2012 @Electromedica.in (Beta) May Version ");
		mainPanel = new JPanel();
		scrollPanel = new JScrollPane(mainPanel,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		statusArea = new JTextArea(TEXT_AREA_WIDTH, TEXT_AREA_HEIGHT);
		statusArea.setEditable(false);
		statusArea
				.append("************************Programming By Bhavin Mehta & Ankit Prasad************************* ...\n\n\n\n");

		layout = new FlowLayout();
		mainPanel.add(statusArea);

		mainPanel.setLayout(layout);
		mainPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

		mainFrame.setResizable(false);
		mainFrame.getContentPane().add(scrollPanel);
		mainFrame.setSize(STATUS_SCREEN_WIDTH, STATUS_SCREEN_HEIGHT);
		mainFrame.setDefaultCloseOperation(CLOSE_OPERATION_VALUE);
		mainFrame.setAlwaysOnTop(true);
		mainFrame.setVisible(true);
	}

	/**
	 * Prints the status line on the status screen
	 * 
	 * @param line
	 *            String
	 */
	public static void printStatus(String line) {
		statusArea.append(line + "\n");
		mainPanel.repaint();
	}

}
